import React, { Component, PureComponent } from 'react'
import TaskList from './TaskList'
import AddTask from './AddTask'
export default class TaskContainer extends PureComponent {
  state = {
    tasks:[
      {
        name:'1',
        isFinish:false
      },
      {
        name:'2',
        isFinish:false
      }
    ]
  }
  componentDidMount(){
    const ts = []
    for(let i = 0;i<10;i++){
      ts.push({
        name:'任务名称'+i,
        isFinish:Math.random()*10 > 7
      })
    }
    this.setState({
      tasks:ts
    })
  }
  HandleAdd =  (val)=>{
    this.setState({
      tasks:[...this.state.tasks,{
        name:val,
        isFinish:false
      }]
    })
}
  render() {
    console.log('TaskContainer',this.state)
    return (
      <>
      <AddTask onAddTask={
       this.HandleAdd
      }
      />
      <TaskList {...this.state}>TaskContainer</TaskList>
      </>
      
    )
  }
}
